using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Text;
using System.Windows.Forms;

using Nairo.Parser.Dom;

namespace Nairo
{
	public abstract class RenderItem
	{
		protected int myTop;
		public int Top
		{
			get { return myTop; }
			set { myTop = value; }
		}

		protected int myLeft;
		public int Left
		{
			get { return myLeft; }
			set { myLeft = value; }
		}

		protected int myWidth;
		public int Width
		{
			get { return myWidth; }
			set { myWidth = value; }
		}

		protected int myHeight;
		public int Height
		{
			get { return myHeight; }
			set { myHeight = value; }
		}

		protected RenderUnit renderUnit;
		public RenderUnit RenderUnit
		{
			get { return renderUnit; }
			set { renderUnit = value; }
		}

		protected HtmlTag element;
		public HtmlTag Element
		{
			get { return element; }
			set { element = value; }
		}

		public RenderItem()
		{
		}

		public RenderItem(int width, int height, HtmlTag element)
		{
			this.myWidth = width;
			this.myHeight = height;
			this.element = element;
		}

		public abstract void Paint(Graphics g);
	}
	
	public class TextRenderItem : RenderItem
	{
		string text;
		public static int paintCounter = 0;
		
		public string Text {
			get { return text; }
			set { text = value; }
		}
		
		public TextRenderItem(string text, int width, int height, HtmlParagraph element)
			: base(width, height, element)
		{
			this.text = text;
		}
		
		public override void Paint(Graphics g)
		{
			paintCounter++;
			HtmlParagraph p = element as HtmlParagraph;
			g.DrawString(this.text, p.Font, new SolidBrush(p.ForeColor), this.Left, this.Top);
//			TextRenderer.DrawText(g, this.text, p.Font, new Point(this.Left, this.Top), p.ForeColor, p.BackColor);
		}
	}
}
